package ustc.xiaoyang.karl.hashtable;

/**
 * 242.有效的字母异位词
 * 1. 排序法
 * 2. 计数法
 */
public class ValidAnagram242 {
    public static void main(String[] args) {

    }
    public boolean isAnagram(String s, String t) {
        if(s.length() != t.length()) return false;
        int[] count = new int[26];
        for (int i = 0; i < s.length(); i++) {
            count[s.charAt(i) - 'a']++;
        }
        for (int i = 0; i < t.length(); i++) {
            count[t.charAt(i) - 'a']--;
        }
        for (int i = 0; i < 26; i++) {
            if(count[i] != 0) return false;
        }

        return true;
    }
}
